package com.aos.erp.common.redis;

import org.springframework.data.redis.core.ZSetOperations;

import java.util.List;
import java.util.Map;
import java.util.Set;

public interface RedisService<K, V> {

    //key 操作
    boolean containsKey(K key);

    boolean removeKey(K key);

    Long getTimeOutValue(K key);


    //String 操作
    boolean saveValue(K key, V value, long time);

    V getValue(K key);


    //Hash 操作
    boolean saveHash(K key, String hashKey, V value, long time);

    boolean saveHash(K key, Map<String, V> map, long time);

    Map<String, V> getHash(K key);

    Set<String> getHashKeys(K key);

    List<V> getHashValues(K key);

    Map<String, V> delHash(K key, String... hashKey);

    // list操作 头部（左边）或者尾部（右边）
    boolean saveListObj(K key, V value, long time);

    boolean saveList(K k, List<V> v, long time);

    List<V> getList(K k, long start, long end);

    long getListSize(K k);

    V delList(K k);

    //Set 操作
    boolean saveSetObj(K k, V v, long time);

    boolean saveSet(K k, Set<V> v, long time);

    Set<V> getSet(K k);

    //Sort Set 操作
    boolean saveZSetObj(K k, V v, double score, long time);

    boolean saveZSet(K k, Set<ZSetOperations.TypedTuple<V>> v, long time);

    Set<V> getZSet(K k, long start, long end);

    Set<V> getZSetByScore(K k, double min, double max);
}
